import request from './api'

const baseUrl = "http://127.0.0.1:9999";
const Service = {

    //登录
    login: data => request.axiosGet(baseUrl + '/api/system/login', data),
    /*
    * 系统管理
    * */
    //组织管理
    searchDepts: data => request.axiosGet(baseUrl + '/api/system/depts/' + data.pageNum + '/' + data.pageSize, data),
    addDepartment: data => request.axiosPost(baseUrl + '/api/system/dept', data),
    updateDepartment: data => request.axiosPut(baseUrl + '/api/system/dept', data),
    deleteDepartment: data => request.axiosDelete(baseUrl + '/api/system/dept/' + data.id, data),

    //菜单管理
    searchMenus: data => request.axiosGet(baseUrl + '/api/system/menus/' + data.pageNum + '/' + data.pageSize, data),
    addMenu: data => request.axiosPost(baseUrl + '/api/system/menu', data),
    updateMenu: data => request.axiosPut(baseUrl + '/api/system/menu', data),
    deleteMenu: data => request.axiosDelete(baseUrl + '/api/system/menu/' + data.id, data),
    getMenuTree: data => request.axiosGet(baseUrl + '/api/system/menu/tree', data),

    //权限管理
    searchPermissions: data => request.axiosGet(baseUrl + '/api/system/permissions/' + data.pageNum + '/' + data.pageSize, data),
    addPermission: data => request.axiosPost(baseUrl + '/api/system/permission', data),
    updatePermission: data => request.axiosPut(baseUrl + '/api/system/permission', data),
    deletePermission: data => request.axiosDelete(baseUrl + '/api/system/permission/' + data.id, data),

    //角色管理
    searchRoles: data => request.axiosGet(baseUrl + '/api/system/roles/' + data.pageNum + '/' + data.pageSize, data),
    addRole: data => request.axiosPost(baseUrl + '/api/system/role', data),
    updateRole: data => request.axiosPut(baseUrl + '/api/system/role', data),
    deleteRole: data => request.axiosDelete(baseUrl + '/api/system/role/' + data.id, data),
    getPermissionsByRole: data => request.axiosGet(baseUrl + '/api/system/role/menus/permissions', data),

    //用户管理
    searchUsers: data => request.axiosGet(baseUrl + '/api/system/admins/' + data.pageNum + '/' + data.pageSize, data),
    addUser: data => request.axiosPost(baseUrl + '/api/system/admin', data),
    updateUser: data => request.axiosPut(baseUrl + '/api/system/admin', data),
    changeUserStatus: data => request.axiosPatch(baseUrl + '/api/system/admin/' + data.id, data),
    deleteUser: data => request.axiosDelete(baseUrl + '/api/system/admin/' + data.id, data),

};

export default Service;
